{{include file="common@layout/_meta_x-admin" /}}
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <input type="hidden" name="id" value="{{$store.id}}">
            {{:widget('common/Form/input',['微信用户','username',$store.user.nickname,true,true,false])}}
            {{:widget('common/Form/input',['公司名称','',$store.company_name,true,true])}}
            {{:widget('common/Form/input',['联系人','',$store.contact_name,true,true])}}
            {{:widget('common/Form/input',['联系电话','',$store.contact_phone,true,true])}}
            <div class="layui-form-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">公司地址</label>
                    <div class="layui-input-block"><input data-field="contact_addr" value="{{$store.contact_addr}}" class="layui-input change" lay-verify="true" /></div>
                </div>
            </div>
            {{:widget('common/Common/image',[$store.attachment,true,'附件'])}}
            <div class="layui-form-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block"><input data-field="memo" value="{{$store.memo}}" class="layui-input change" /></div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <div class="layui-input-block">
                    <button type="button" class="layui-btn" lay-submit lay-filter="submitForm" id="success">通过</button>
                    <button class="layui-btn layui-btn-danger" lay-submit lay-filter="submitForm" id="fail">不通过</button>
                </div>
            </div>
        </form>
    </div>
</div>
</body>
<script>
    $(function(){
        $(".change").change(function () {
            var _this = $(this)
            $.ajax({
                url:"edit",type:"post",dataType:"json",
                data:{id:"{{$store.id}}", field:_this.data('field'),value:_this.val()},
                success:function () {
                    layer.msg('修改成功')
                }
            })
        })
    })
    layui.use(['form','jquery'], function(){
        var form = layui.form;
        var $ = layui.jquery;

        //监听提交
        form.on('submit(submitForm)', function(data){
            var status = $(this).attr('id');
            status === 'fail' ? status = 2 : status = 3;
            var postData = {
                id : data.field.id,
                status : status,
                memo : data.field.memo
            }
            ajaxRequest('',postData);
            return false;
        });
    });



</script>